from PyPDF2 import PdfFileReader, PdfFileWriter
from pdfminer import high_level

input_pdf = PdfFileReader("解释器.pdf")
output_pdf = PdfFileWriter()
output_pdf.appendPagesFromReader(input_pdf)
output_pdf.encrypt("password")
with open("解释器2.pdf", "wb") as out_file:
    output_pdf.write(out_file)

text = high_level.extract_text('解释器2.pdf', password='password')
print(text)
